You can help by commenting or suggesting your edit directly into the transcript. We'll review any changes before posting them. All comments are completely anonymous. For any comments that need a reply, consider emailing training@inductiveautomation.com.
Version:
LESSON LIST
-
3:26Begin Step and Using Parameters
-
1:04End Step
-
2:49Action Step
-
3:11Transition
-
4:03Enclosing Step
-
2:59Parallel Element
-
1:44Jump and Anchor
-
0:43Note
LESSON
Action Step
Description
Here is a detailed explanation of how the Action Step functions in a Sequential Function Chart. You can configure the Action Step to function On Start, On Stop, as Timer, or an Error Handler. This video loops using a chart counter variable as its example.
Video recorded using: Ignition 8.1
Transcript
(open in window)[00:00] In this lesson, I'll introduce the "action step" SFC element. Action steps are one of the most important elements as they do the bulk of the work in SFCs. Action steps work by adding a certain number of actions to them. These actions allow you to write Python scripts to do things like write to tags or execute SQL queries. Depending on the action selected, they'll fire at specific times during the steps lifecycle. The first option here, OnStart will fire when the step first starts. It'll be the first script to run for this step and is guaranteed to run once. After adding the action, a Python function will be created for you and it's passed two parameters, chart and step. Chart is a reference to the chart scope, which lasts for the entire lifetime of the chart instance, and step is a reference to the step scope, which only lasts as long as the current step is running. The next option OnStop will fire as the step is stopping and just like the OnStart action is guaranteed to run once. Next is the Timer action.
[01:02] Unlike the OnStart and Stop actions, the timer is not guaranteed to run. Timer actions will only fire if there's a transition step below this action step that's currently set to false. Then it needs to be false for a sufficient amount of time for the timer to run. That time will depend on the rate that you set for the timer action. You can add as many timers as you'd like, but be aware they will not run at the same time. If an action takes a long time to finish executing, it will block other actions from executing. If multiple actions need to be run at the same time, use a parallel section. Finally, there's the Error Handler action. This action will only run if any of the other actions throw an unexpected error. This provides an opportunity to perform your own error handling and gracefully handle those errors. Normally, if errors aren't caught in the other actions or if this script throws an error, a chart will abort. I'll set up a quick example chart to demonstrate the behavior of the action step. I'll add an OnStart script that initializes some chart variables. I'll add a message that says, "I started", and then a counter set to zero.
[02:07] Next, I'll configure a timer script to fire every one second that increments the counter. Then I'll add an OnStop script that updates the chart message to say, "I'm done". Finally, I'll add a transition step below the action step that's true when the counter is greater than five. Now, if I start a chart instance, we can see the message be initialized, the counter increments, and then the message will let us know that the chart is done.